package com.lanyan.system.controller.api;

import com.lanyan.common.annotation.RepeatSubmit;

import java.math.BigDecimal;

import com.lanyan.common.utils.SecurityUtils;
import io.swagger.annotations.Api;

import java.util.List;
import java.util.Date;

import com.lanyan.common.core.domain.R;
import com.lanyan.common.core.domain.PageR;

import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lanyan.common.annotation.Log;
import io.swagger.annotations.ApiOperation;
import com.lanyan.common.core.controller.BaseController;
import com.lanyan.common.core.domain.AjaxResult;
import com.lanyan.common.core.domain.R;
import com.lanyan.common.enums.BusinessType;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import springfox.documentation.annotations.ApiIgnore;
import com.lanyan.common.utils.StringUtils;
import com.lanyan.system.domain.BalanceHistory;
import com.lanyan.system.domain.vo.BalanceHistoryVo;
import com.lanyan.system.service.IBalanceHistoryService;
import com.lanyan.common.utils.poi.ExcelUtil;
import com.lanyan.common.core.page.TableDataInfo;

/**
 * 余额流水Controller
 *
 * @author lanyan
 * @date 2024-11-26
 */
@RestController
@Api(tags = {"余额流水" })
@RequestMapping("/api/balanceHistory")
public class ApiBalanceHistoryController extends BaseController {
    @Autowired
    private IBalanceHistoryService balanceHistoryService;

/**
 * 查询余额流水列表
 */
@GetMapping("/page")
@ApiImplicitParams({
        @ApiImplicitParam(name = "pageNum", value = "第几页", dataType = "int", dataTypeClass = int.class),
        @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", dataTypeClass = int.class),

})
@ApiOperation("查询余额流水列表")
    public PageR<BalanceHistory> list(@ApiIgnore BalanceHistory balanceHistory) {
        startPage();
        balanceHistory.setAccountId(SecurityUtils.getUserId());
        List<BalanceHistory> list = balanceHistoryService.selectBalanceHistoryList(balanceHistory);
        return PageR.page(list);
    }

//    /**
//     * 获取余额流水详细信息
//     */
//    @GetMapping(value = "/info")
//    @ApiOperation("获取余额流水详细信息")
//    public R<BalanceHistory> getInfo(Long balanceHistoryId) {
//        return R.ok(balanceHistoryService.selectBalanceHistoryByBalanceHistoryId(balanceHistoryId));
//    }
//
//    /**
//     * 新增余额流水
//     */
//    @Log(title = "余额流水", businessType = BusinessType.INSERT)
//    @PostMapping("save")
//    @ApiImplicitParams({
//        @ApiImplicitParam(name = "delFlag", value = "删除标志（0代表存在 2代表删除）", dataType = "String", dataTypeClass = String.class),
//        @ApiImplicitParam(name = "createBy", value = "创建者", dataType = "String", dataTypeClass = String.class),
//        @ApiImplicitParam(name = "createTime", value = "创建时间", dataType = "Date", dataTypeClass = Date.class),
//        @ApiImplicitParam(name = "updateBy", value = "更新者", dataType = "String", dataTypeClass = String.class),
//        @ApiImplicitParam(name = "updateTime", value = "更新时间", dataType = "Date", dataTypeClass = Date.class),
//        @ApiImplicitParam(name = "remark", value = "备注", dataType = "String", dataTypeClass = String.class),
//        @ApiImplicitParam(name = "accountId", value = "所属用户", dataType = "Long", dataTypeClass = Long.class),
//        @ApiImplicitParam(name = "money", value = "金额", dataType = "BigDecimal", dataTypeClass = BigDecimal.class),
//        @ApiImplicitParam(name = "type", value = "类型（0微信）", dataType = "String", dataTypeClass = String.class),
//        @ApiImplicitParam(name = "title", value = "标题", dataType = "String", dataTypeClass = String.class),
//        @ApiImplicitParam(name = "message", value = "消费信息", dataType = "String", dataTypeClass = String.class),
//        @ApiImplicitParam(name = "pointTo", value = "指向", dataType = "String", dataTypeClass = String.class),
//    })
//    @RepeatSubmit
//    @ApiOperation("新增余额流水")
//    public R<BalanceHistory> add(@ApiIgnore @RequestBody BalanceHistory balanceHistory) {
//        StringUtils.insertRequired(balanceHistory);
//        balanceHistoryService.insertBalanceHistory(balanceHistory);
//        return R.ok(balanceHistory);
//    }
//
//    /**
//     * 修改余额流水
//     */
//    @Log(title = "余额流水", businessType = BusinessType.UPDATE)
//    @PostMapping("update")
//    @ApiImplicitParams({
//                    @ApiImplicitParam(name = "createBy", value = "创建者", dataType = "String", dataTypeClass = String.class),
//                    @ApiImplicitParam(name = "createTime", value = "创建时间", dataType = "Date", dataTypeClass = Date.class),
//                    @ApiImplicitParam(name = "updateBy", value = "更新者", dataType = "String", dataTypeClass = String.class),
//                    @ApiImplicitParam(name = "updateTime", value = "更新时间", dataType = "Date", dataTypeClass = Date.class),
//                    @ApiImplicitParam(name = "remark", value = "备注", dataType = "String", dataTypeClass = String.class),
//                    @ApiImplicitParam(name = "accountId", value = "所属用户", dataType = "Long", dataTypeClass = Long.class),
//                    @ApiImplicitParam(name = "money", value = "金额", dataType = "BigDecimal", dataTypeClass = BigDecimal.class),
//                    @ApiImplicitParam(name = "title", value = "标题", dataType = "String", dataTypeClass = String.class),
//                    @ApiImplicitParam(name = "message", value = "消费信息", dataType = "String", dataTypeClass = String.class),
//                    @ApiImplicitParam(name = "pointTo", value = "指向", dataType = "String", dataTypeClass = String.class),
//    })
//    @RepeatSubmit
//    @ApiOperation("修改余额流水")
//    public AjaxResult edit(@ApiIgnore @RequestBody BalanceHistory balanceHistory) {
//        StringUtils.updateRequired(balanceHistory);
//        balanceHistoryService.updateBalanceHistory(balanceHistory);
//        return success("修改成功");
//    }
//
//    /**
//     * 删除余额流水
//     */
//    @Log(title = "余额流水", businessType = BusinessType.DELETE)
//    @GetMapping("/del")
//    @ApiOperation("删除余额流水")
//    public AjaxResult remove(Long balanceHistoryId) {
//        balanceHistoryService.deleteBalanceHistoryByBalanceHistoryId(balanceHistoryId);
//        return success("删除成功");
//    }
}
